
// 汤姆视频
if((0 == window.location.href.indexOf("https://tom") || 0 == window.location.href.indexOf("https://tm")
	|| -1 != window.location.href.indexOf("tom.com"))
	&& -1 != document.getElementsByTagName('body')[0].innerText.indexOf("汤姆影院")) {
	console.log("汤姆视频");

	$('div.helpCenter').remove();
	$('div.play.container_all div.play-banner-A1').remove();
	$('div.play.container_all div.play-banner-A2').remove();
	$('div.play.container_all div.play-title-T1').remove();
	$('div.play.container_all div.dv2').css("margin", "50px 0 0 0");
	$('div.play_jinyon_btn').remove();	// 付费视频的屏蔽层
	$('header#head_wrap div.con').remove();
	$('header#head_wrap div.head').remove();
	$('div#gotoTop').remove();
	// $('.topPCjjv.pcjjvCom').remove();
	// $('.advcom.pladv').remove();
	$('nav').css('height', '16px');
	$('nav img').remove();
	$('.navList ul li a').css('line-height', '');
	$('.zedancen.play_islogin_tc').remove();

	$(function() {
		var iframeUrl = $('#iframe').attr('src');
		var m3u8Url = iframeUrl.split('?url=')[1];

		var $playBottomNew = $("div.play.container_all > div.play-bottom-new");
		var $movieName = $playBottomNew.find('h5:first');
		var movieName = $.trim($movieName.text());
		var tempName = $.md5(m3u8Url);
		var textArea = '<textarea  rows="15" cols="136">';
		textArea += tempName + '.bat\n\n\n\n';
		textArea += 'ffmpeg -i "' + m3u8Url + '" -c copy ' + tempName + '.mp4\n';
		textArea += 'ren ' + tempName + '.mp4 "' + movieName + '.mp4"\n';
		textArea += 'pause\n';
		textArea += '</textarea>';
		var $textArea = $(textArea);
		$playBottomNew.after($textArea);
		$playBottomNew.remove();

		InsertDownloadM3u8Btn($textArea, m3u8Url, movieName);
	});

	// 标题栏显示原始的视频名, 添加 复制视频名 的按钮
	$downloadUrl = $("body > div.play.container_all > div.dv3 #xunlei_nr1 > input");
	$downloadUrlAd = $("body > div.play.container_all > div.dv3 #xunlei_gaoqing > a");
	InsertSelectBtn($downloadUrlAd, $downloadUrl);
	$downloadUrlAd.remove();

	$("#xunlei_gaoqing").click(function() {
		copyText($("#xunlei_nr1 > input").val());
	});

	// $('.dv3.h5_left_yc_xunleixiazai_fuzhi .lul .li2 a').click();
	$('html , body').animate({scrollTop: 0}, 100);
}

// 爽爽影院, 生成FFMPEG下载的批处理文件
var ssyyDomains = ["www.tingyouke.com/index.php/vod/play/", "https://www.bonaadd.com/index.php/vod/play/"];
var isSSYY = false;
for(domainIdx in ssyyDomains) {
	if(-1 != window.location.href.indexOf(ssyyDomains[domainIdx])) {
		isSSYY = true;
		break;
	}
}
if(isSSYY) {
	console.log("爽爽影院, 生成FFMPEG下载的批处理文件");

	eval($('.fed-play-loader.fed-part-full > script').html());
	console.log('player_data url', player_data.url);
	var movieName = $('.fed-part-eone.fed-font-xvi:eq(3) > a').text();
	movieName = $.trim(movieName);
	if("" == movieName) {
		movieName = $('.fed-tabs-info.fed-rage-foot').data('name');
		movieName = $.trim(movieName);
	}

	var tempName = $.md5(window.location.href);
	var textArea = '<textarea  rows="8" cols="80">';
	textArea += tempName + '.bat\n\n';
	textArea += 'ffmpeg -i "' + player_data.url + '" -c copy ' + tempName + '.mp4\n';
	textArea += 'ren ' + tempName + '.mp4 "' + movieName + '.mp4"\n';
	textArea += 'pause\n';
	textArea += '</textarea>';
	$('.fed-play-info').after(textArea);

	InsertDownloadM3u8Btn($('.fed-part-case'), player_data.url, movieName);
}

// 黄色仓库
if((
		0 == window.location.href.indexOf("http://57ck.cc/")
		|| 0 == window.location.href.indexOf("http://hscangku.com/")
		|| 0 == window.location.href.indexOf("http://78ck.cc/")
		|| 0 == window.location.href.indexOf("http://255ck.com/")
	)
	|| -1 != document.title.indexOf("黄色仓库")) {
	console.log("黄色仓库");

	$('div.container').prevAll('a').remove();	// 删除上方广告
	$('div:first:not(".container")').remove();	// 删除上方广告
	$('div.container div.stui-pannel').nextAll('a').remove();	// 删除下方广告
	$('div.container div.stui-warp-head').remove();	// 删除左方菜单
	$('#rm-float3').remove();	// 删除下方浮动广告

	var $movieName = $('.stui-warp-content h3.title:first');
	$movieName.css('float', 'left');
	// $(function() {
		setTimeout(function() {
			// 在BODY里注入JS, 获取存储视频地址的变量值
			var script = document.createElement('script');
			script.type = 'text/javascript';
			script.innerHTML = "document.body.setAttribute('data-m3u8url', player_aaaa.url);";
			document.head.appendChild(script);
			document.head.removeChild(script);

			// 从BODY属性里取得视频地址
			var m3u8Url = document.body.getAttribute('data-m3u8url');
			var $playFoot = $("div.stui-player__foot");
			var movieName = $.trim($movieName.text());
			$movieName.text(movieName);
			var tempName = $.md5(m3u8Url);
			var textArea = '<textarea  rows="15" cols="136">';
			textArea += tempName + '.bat\n\n\n\n';
			textArea += 'ffmpeg -i "' + m3u8Url + '" -c copy ' + tempName + '.mp4\n';
			textArea += 'ren ' + tempName + '.mp4 "' + movieName + '.mp4"\n';
			textArea += 'pause\n';
			textArea += '</textarea>';
			$playFoot.after(textArea);

			InsertDownloadM3u8Btn($movieName, m3u8Url, movieName);
		}, 5000);
	// });

	// 标题栏显示原始的视频名, 添加 复制视频名 的按钮
	InsertSelectBtn($movieName, $movieName, '选择视频名');
	$('html , body').animate({scrollTop: 0}, 100);
}
